package com.haoxi.gateway.util.db;

import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.dbcp.BasicDataSource;

/**
 * <p>Title: l����ݿ�</p>
 * <p>Description: l����ݿ�</p>
 * <p>Copyright: Copyright (c) 2006</p>
 * @author Cloud
 * @version 1.1
 */

public class BaseData extends BasicDataSource implements Configurable{
	
	/**
	 * datasource name
	 */
    private String name;
    
    public BaseData(Configuration conf)throws ConfigurationException {
        configure(conf);
    }
    
    public void configure(Configuration conf)throws ConfigurationException{
        //datasource name
    	name = conf.getAttribute("name");
        
        setDriverClassName(conf.getChild("driver").getValue());
        setUrl(conf.getChild("url").getValue());
        setUsername(conf.getChild("user").getValue());
        setPassword(conf.getChild("pwd").getValue());
        setMaxActive(conf.getChild("maxactive").getValueAsInteger());
        setMaxIdle(conf.getChild("maxidle").getValueAsInteger());
        setMaxWait(conf.getChild("maxwait").getValueAsLong()); 
    }
    
    /**
     * get/set date source name
     * @return
     */
	public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
